package com.common.controller;

import com.common.es.service.EsIndexOperation;
import com.common.hbase.HbaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 牧鱼
 * @Classname ESTestController
 * @Description TODO
 * @Date 2021/5/10
 */
@RestController
@RequestMapping("/esTest")
public class ESTestController {

    @Autowired
    private EsIndexOperation esIndexOperation;

    @Autowired
    private HbaseService hbaseService;

    @GetMapping("/index/{indexName}")
    public boolean isIndex(@PathVariable("indexName") String indexName){
        return esIndexOperation.checkIndex(indexName);
    }

    @PostMapping("/index/{indexName}")
    public boolean createIndex(@PathVariable("indexName") String indexName , @RequestBody Map<String, ?> mapping){
        return esIndexOperation.createIndex(indexName,mapping);
    }

    @DeleteMapping("/index/{indexName}")
    public boolean createIndex(@PathVariable("indexName") String indexName ){
        return esIndexOperation.deleteIndex(indexName);
    }

}
